/**
  * @addtogroup 
  * 
  *
  * @brief 
  *
  * @code{c}
  * @endcode
  * @{
  * @file         bsc_electric_fence_zone_data.h
  * @brief        定义区域相关数据结构体
  * @note
  * @author       Jpz(puzhao.jin@hopechart，靳普诏)
  * @date         2022-09-22
  * @version      1.0
  * 
  * @par          修改日志
  * <table>
  * <tr><th>Date        <th>Version          <th>Author                        <th>Description
  * <tr><td>2022-09-22  <td>1.0              <td>Jpz                           <td>创建初始版本
  * @copyright    杭州鸿泉物联网技术股份有限公司
  */



#ifndef _BSC_ELECTRIC_FENCE_ZONE_DATA_H_
#define _BSC_ELECTRIC_FENCE_ZONE_DATA_H_

// ~~~~~~~~~~~~ 统一包含头文件 ~~~~~~~~~~~~

#include "bsc_electric_fence/bsc_electric_fence_define.h"


// #define BSC_Electric_FENCE_EXTERN_INFO_SIZE 12  // 区域信息拓展空间大小

#ifdef __cplusplus
extern "C" {
#endif


enum TBsElectricFenceShapeTag
{
    kBsElectricFenceShapeCircle = 0,     ///< 圆形区域
    kBsElectricFenceShapeRect   = 1,     ///< 矩形区域
    kBsElectricFenceShapePoly   = 2,     ///< 多边形
    kBsElectricFenceShapeLine   = 3,     ///< 线路
    kBsElectricFenceShapeMax         ///< 区域种类最大值
};
typedef enum TBsElectricFenceShapeTag TBsElectricFenceShape;


typedef struct TBsElectricFencePoinTag TBsElectricFencePoint;
struct TBsElectricFencePoinTag
{
    Int32 latitude;               ///< 纬度
    Int32 longitude;              ///< 经度
};


// ~~~~~~~~~~~~~~~~ 区域信息 ~~~~~~~~~~~~~~~~~~~~~~

/// @note 通过平台对象接口获取区域信息时完成赋值
typedef struct TBsElectricFenceZoneBaseInfoTag TBsElectricFenceZoneBaseInfo;
struct TBsElectricFenceZoneBaseInfoTag
{
    UInt32 zone_id;             ///< 区域id。每种区域的id应该唯一。

    UInt32 start_time;          ///< 起始时间。 当起始时间 <= 结束时间时，禁行功能有效
    UInt32 stop_time;           ///< 结束时间。

    UInt16 speed_max;           ///< 允许最高速度，单位 km/h。 当需要屏蔽时设为极大值
    UInt16 over_speed_duration; ///< 超速允许持续时长，单位 s。（测试时设为0，保证每次触发）    

    UInt32 zone_attr;           ///< 区域标准属性（组件内不做逻辑处理，在通知回调中交由用户判断处理）
};

typedef struct TBsElectricFenceZoneExtInfoTag TBsElectricFenceZoneExtInfo;
struct TBsElectricFenceZoneExtInfoTag
{
    UInt32          extern_info_size;     ///< 拓展信息大小
    Byte            extern_info[1];       ///< 拓展信息  
};  


// ~~~~~~~~~~~~~~~~ 圆形区域 ~~~~~~~~~~~~~

typedef struct TBsElectricFenceCircleTag TBsElectricFenceCircle;
struct TBsElectricFenceCircleTag
{
    UInt32                  radius;
    TBsElectricFencePoint  point;
};  


typedef struct TBsElectricFenceZoneCircleInfoTag TBsElectricFenceZoneCircleInfo;
struct TBsElectricFenceZoneCircleInfoTag
{
    TBsElectricFenceZoneBaseInfo    info;
    TBsElectricFenceCircle     shape;
    TBsElectricFenceZoneExtInfo ext_info;
};  


// ~~~~~~~~~~~~~~~~ 矩形区域 ~~~~~~~~~~~~~

typedef struct TBsElectricFenceRectTag TBsElectricFenceRect;
struct TBsElectricFenceRectTag
{
    TBsElectricFencePoint left_top;
    TBsElectricFencePoint right_botom;
};

typedef struct TBsElectricFenceZoneRectInfoTag TBsElectricFenceZoneRectInfo;
struct TBsElectricFenceZoneRectInfoTag
{
    TBsElectricFenceZoneBaseInfo    info;
    TBsElectricFenceRect     shape;
    TBsElectricFenceZoneExtInfo ext_info;
};

// ~~~~~~~~~~~~~~~~ 多边形区域 ~~~~~~~~~~~~~

typedef struct TBsElectricFencePolyTag TBsElectricFencePoly;
struct TBsElectricFencePolyTag
{
    UInt16          reserved;  ///< 对齐保留
    UInt16          count;     ///< 多边形顶点数
    TBsElectricFencePoint point[16];  ///< 顶点
};

typedef struct TBsElectricFenceZonePolyInfoTag TBsElectricFenceZonePolyInfo;
struct TBsElectricFenceZonePolyInfoTag
{
    TBsElectricFenceZoneBaseInfo    info;
    TBsElectricFencePoly     shape;
    TBsElectricFenceZoneExtInfo ext_info;
};

// ~~~~~~~~~~~~~~~~ 路线区域 ~~~~~~~~~~~~~

// 拐点
typedef struct TBsElectricFenceInflectionTag TBsElectricFenceInflection;
struct TBsElectricFenceInflectionTag
{
    TBsElectricFencePoint     point1;
    UInt8  width;              ///< 路段宽度
    UInt8  reserved1[3];       ///< 保留字节
};

typedef struct TBsElectricFenceLineTag TBsElectricFenceLine;
struct TBsElectricFenceLineTag
{
    UInt16  count;              ///< 拐点个数
    UInt8  reserved1[2];       ///< 保留字节
    TBsElectricFenceInflection     *Inflection;
};

typedef struct TBsElectricFenceZoneLineInfoTag TBsElectricFenceZoneLineInfo;
struct TBsElectricFenceZoneLineInfoTag
{
    TBsElectricFenceZoneBaseInfo    info;
    TBsElectricFenceLine     shape;
    TBsElectricFenceZoneExtInfo ext_info;
};



#ifdef __cplusplus
}  ///< extern "C" {
#endif


#endif

